package br.siseventos.model;
// Generated 29/10/2012 23:23:36 by Hibernate Tools 3.2.1.GA

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * TbServico generated by hbm2java
 */
@Entity
@Table(name = "tb_servico", catalog = "SisEventosDB", uniqueConstraints =
@UniqueConstraint(columnNames = "nme_servico"))
public class TbServico extends BaseModel{

    private Integer idtServico;
    private String nmeServico;
    private String dscServico;
    private Set<TaPedidoServico> taPedidoServicos = new HashSet<TaPedidoServico>(0);
    private Set<TaPermissaoServico> taPermissaoServicos = new HashSet<TaPermissaoServico>(0);
    private Set<TaServicoPrestador> taServicoPrestadors = new HashSet<TaServicoPrestador>(0);

    public TbServico() {
    }

    public TbServico(String nmeServico) {
        this.nmeServico = nmeServico;
    }

    public TbServico(String nmeServico, String dscServico, Set<TaPedidoServico> taPedidoServicos, Set<TaPermissaoServico> taPermissaoServicos, Set<TaServicoPrestador> taServicoPrestadors) {
        this.nmeServico = nmeServico;
        this.dscServico = dscServico;
        this.taPedidoServicos = taPedidoServicos;
        this.taPermissaoServicos = taPermissaoServicos;
        this.taServicoPrestadors = taServicoPrestadors;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "idt_servico", unique = true, nullable = false)
    public Integer getIdtServico() {
        return this.idtServico;
    }

    public void setIdtServico(Integer idtServico) {
        this.idtServico = idtServico;
    }

    @Column(name = "nme_servico", unique = true, nullable = false, length = 80)
    public String getNmeServico() {
        return this.nmeServico;
    }

    public void setNmeServico(String nmeServico) {
        this.nmeServico = nmeServico;
    }

    @Column(name = "dsc_servico", length = 200)
    public String getDscServico() {
        return this.dscServico;
    }

    public void setDscServico(String dscServico) {
        this.dscServico = dscServico;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbServico")
    public Set<TaPedidoServico> getTaPedidoServicos() {
        return this.taPedidoServicos;
    }

    public void setTaPedidoServicos(Set<TaPedidoServico> taPedidoServicos) {
        this.taPedidoServicos = taPedidoServicos;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbServico")
    public Set<TaPermissaoServico> getTaPermissaoServicos() {
        return this.taPermissaoServicos;
    }

    public void setTaPermissaoServicos(Set<TaPermissaoServico> taPermissaoServicos) {
        this.taPermissaoServicos = taPermissaoServicos;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbServico")
    public Set<TaServicoPrestador> getTaServicoPrestadors() {
        return this.taServicoPrestadors;
    }

    public void setTaServicoPrestadors(Set<TaServicoPrestador> taServicoPrestadors) {
        this.taServicoPrestadors = taServicoPrestadors;
    }
    // Sobrescrevendo metodos utilitarios importantes   
    @Override
    public String toString() {
        return this.nmeServico;
    }

    @Override
    public boolean equals(Object outro) {
        return (outro instanceof TbServico) && (this.idtServico != null)
                ? idtServico.equals(((TbServico) outro).getIdtServico())
                : (outro == this);
    }

    @Override
    public int hashCode() {
        return (idtServico != null)
                ? (this.getClass().hashCode() + idtServico.hashCode())
                : super.hashCode();
    }
}
